OpenBuildings GenerativeComponents Help

Simple Statements versus Compound Statements

A GCScript statement has either of two forms, depending on whether it's a simple statement or a compound statement. A simple statement comprises the body of the statement, followed by a semicolon character.

General Form of a Simple Statement

statement

A compound statement comprises a sequence of statements enclosed within curly braces. There is not a semicolon after the closing curly brace.

{
	statement
	statement2
	…
	statementn
}

The definition of a compound statement is recursive: Each embedded statement can, itself, be either a simple statement or a compound statement.

So, for example, the general form of the 'if' statement is as follows:

if (expression)
	statement

Since the nested statement can be either a simple statement or a compound statement, both of the following are legitimate examples of 'if' statements:

if (radius < 20)
	radius = 20;           //
Simple statement.
if (radius < 20)
{ 
	radius = 20; 
	Print('The radius was too small.');
}                                    
   // End of compound statement.